#include <srts/stratego.h>
#include <stratego-lib/stratego-lib.h>
void init_constructors (void)
{
}
static Symbol sym__3;
static Symbol sym_Nil_0;
static Symbol sym_None_0;
static Symbol sym_IntConst_1;
static Symbol sym_Declaration2_2;
static Symbol sym_Id_1;
static Symbol sym_TypeId_1;
static Symbol sym_IdDecl_3;
static Symbol sym_Promote_0;
static Symbol sym_TypeSpec_3;
static Symbol sym_DeclSpec_2;
static Symbol sym_TypeName_2;
static Symbol sym_Pointer_2;
static Symbol sym_ArrayDecl_1;
static Symbol sym_Some_1;
static Symbol sym_Cons_2;
static void init_module_constructors (void)
{
sym__3 = ATmakeSymbol("", 3, ATfalse);
ATprotectSymbol(sym__3);
sym_Nil_0 = ATmakeSymbol("Nil", 0, ATfalse);
ATprotectSymbol(sym_Nil_0);
sym_None_0 = ATmakeSymbol("None", 0, ATfalse);
ATprotectSymbol(sym_None_0);
sym_IntConst_1 = ATmakeSymbol("IntConst", 1, ATfalse);
ATprotectSymbol(sym_IntConst_1);
sym_Declaration2_2 = ATmakeSymbol("Declaration2", 2, ATfalse);
ATprotectSymbol(sym_Declaration2_2);
sym_Id_1 = ATmakeSymbol("Id", 1, ATfalse);
ATprotectSymbol(sym_Id_1);
sym_TypeId_1 = ATmakeSymbol("TypeId", 1, ATfalse);
ATprotectSymbol(sym_TypeId_1);
sym_IdDecl_3 = ATmakeSymbol("IdDecl", 3, ATfalse);
ATprotectSymbol(sym_IdDecl_3);
sym_Promote_0 = ATmakeSymbol("Promote", 0, ATfalse);
ATprotectSymbol(sym_Promote_0);
sym_TypeSpec_3 = ATmakeSymbol("TypeSpec", 3, ATfalse);
ATprotectSymbol(sym_TypeSpec_3);
sym_DeclSpec_2 = ATmakeSymbol("DeclSpec", 2, ATfalse);
ATprotectSymbol(sym_DeclSpec_2);
sym_TypeName_2 = ATmakeSymbol("TypeName", 2, ATfalse);
ATprotectSymbol(sym_TypeName_2);
sym_Pointer_2 = ATmakeSymbol("Pointer", 2, ATfalse);
ATprotectSymbol(sym_Pointer_2);
sym_ArrayDecl_1 = ATmakeSymbol("ArrayDecl", 1, ATfalse);
ATprotectSymbol(sym_ArrayDecl_1);
sym_Some_1 = ATmakeSymbol("Some", 1, ATfalse);
ATprotectSymbol(sym_Some_1);
sym_Cons_2 = ATmakeSymbol("Cons", 2, ATfalse);
ATprotectSymbol(sym_Cons_2);
}
static ATerm term3;
static ATerm term2;
static ATerm term1;
static ATerm term0;
static void init_module_constant_terms (void)
{
ATprotect(&(term0));
term0 = (ATerm) ATmakeAppl(sym_None_0);
ATprotect(&(term1));
term1 = term0;
ATprotect(&(term2));
term2 = (ATerm) ATmakeAppl(sym_Promote_0);
ATprotect(&(term3));
term3 = term2;
}
#include <srts/init-stratego-application.h>
extern const char * __tracing_table [];
extern unsigned short __tracing_table_counter;
ATerm io_wrap_1_0 (StrSL sl, StrCL g_41, ATerm t);
ATerm Declare1D_0_0 (StrSL sl, ATerm t);
ATerm main_0_0 (StrSL sl, ATerm t);
ATerm Declare1D_0_0 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "Declare1D_0_0";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
{
ATerm trm0 = t;
ATerm x_16 = NULL,y_16 = NULL,z_16 = NULL;
if(match_cons(t, sym__3))
{
ATerm trm1 = ATgetArgument(t, 0);
if(match_cons(trm1, sym_Id_1))
{
x_16 = ATgetArgument(trm1, 0);
}
else
goto label1 ;
y_16 = ATgetArgument(t, 1);
z_16 = ATgetArgument(t, 2);
}
else
goto label1 ;
t = (ATerm) ATmakeAppl(sym__3, (ATerm)ATmakeAppl(sym_TypeName_2, (ATerm)ATmakeAppl(sym_TypeSpec_3, (ATerm)ATempty, (ATerm)ATmakeAppl(sym_TypeId_1, x_16), (ATerm) ATempty), term1), y_16, z_16);
t = Declare1D_0_0(sl, t);
if((t == NULL))
goto label1 ;
goto label0 ;
label1 :
t = trm0;
{
ATerm trm2 = t;
ATerm u_16 = NULL,v_16 = NULL,w_16 = NULL;
if(match_cons(t, sym__3))
{
ATerm trm3 = ATgetArgument(t, 0);
if(match_cons(trm3, sym_TypeName_2))
{
u_16 = ATgetArgument(trm3, 0);
{
ATerm trm4 = ATgetArgument(trm3, 1);
if(!(match_cons(trm4, sym_None_0)))
goto label2 ;
}
}
else
goto label2 ;
{
ATerm trm5 = ATgetArgument(t, 1);
if(match_cons(trm5, sym_Id_1))
{
v_16 = ATgetArgument(trm5, 0);
}
else
goto label2 ;
}
{
ATerm trm6 = ATgetArgument(t, 2);
if(match_cons(trm6, sym_IntConst_1))
{
w_16 = ATgetArgument(trm6, 0);
}
else
goto label2 ;
}
}
else
goto label2 ;
t = (ATerm) ATmakeAppl(sym_Declaration2_2, (ATerm)ATmakeAppl(sym_DeclSpec_2, (ATerm)ATinsert(ATempty, term3), u_16), (ATerm) ATinsert(ATempty, (ATerm) ATmakeAppl(sym_IdDecl_3, (ATerm)ATempty, (ATerm)ATmakeAppl(sym_Id_1, v_16), (ATerm) ATmakeAppl(sym_Some_1, (ATerm) ATinsert(ATempty, (ATerm) ATmakeAppl(sym_ArrayDecl_1, (ATerm) ATmakeAppl(sym_IntConst_1, w_16)))))));
goto label0 ;
label2 :
t = trm2;
{
ATerm q_16 = NULL,r_16 = NULL,s_16 = NULL,t_16 = NULL;
if(match_cons(t, sym__3))
{
ATerm trm7 = ATgetArgument(t, 0);
if(match_cons(trm7, sym_TypeName_2))
{
q_16 = ATgetArgument(trm7, 0);
{
ATerm trm8 = ATgetArgument(trm7, 1);
if(match_cons(trm8, sym_Some_1))
{
ATerm trm9 = ATgetArgument(trm8, 0);
if(match_cons(trm9, sym_Pointer_2))
{
r_16 = ATgetArgument(trm9, 0);
{
ATerm trm10 = ATgetArgument(trm9, 1);
if(!(match_cons(trm10, sym_None_0)))
goto fail1 ;
}
}
else
goto fail1 ;
}
else
goto fail1 ;
}
}
else
goto fail1 ;
{
ATerm trm11 = ATgetArgument(t, 1);
if(match_cons(trm11, sym_Id_1))
{
s_16 = ATgetArgument(trm11, 0);
}
else
goto fail1 ;
}
{
ATerm trm12 = ATgetArgument(t, 2);
if(match_cons(trm12, sym_IntConst_1))
{
t_16 = ATgetArgument(trm12, 0);
}
else
goto fail1 ;
}
}
else
goto fail1 ;
t = (ATerm) ATmakeAppl(sym_Declaration2_2, (ATerm)ATmakeAppl(sym_DeclSpec_2, (ATerm)ATinsert(ATempty, term3), q_16), (ATerm) ATinsert(ATempty, (ATerm) ATmakeAppl(sym_IdDecl_3, r_16, (ATerm)ATmakeAppl(sym_Id_1, s_16), (ATerm) ATmakeAppl(sym_Some_1, (ATerm) ATinsert(ATempty, (ATerm) ATmakeAppl(sym_ArrayDecl_1, (ATerm) ATmakeAppl(sym_IntConst_1, t_16)))))));
goto label0 ;
}
}
label0 :
;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail1 :
--__tracing_table_counter;
return(NULL);
}
ATerm main_0_0 (StrSL sl, ATerm t)
{
__tracing_table[__tracing_table_counter++] = "main_0_0";
__tracing_table[__tracing_table_counter] = NULL;
sl_decl(sl);
{
struct str_closure r_163 = { &(Declare1D_0_0) , sl };
StrCL lifted0_cl = &(r_163);
t = io_wrap_1_0(sl, lifted0_cl, t);
if((t == NULL))
goto fail0 ;
}
__tracing_table[--__tracing_table_counter] = NULL;
return(t);
fail0 :
--__tracing_table_counter;
return(NULL);
}
static void register_strategies (void)
{
int initial_size = 117;
int max_load = 75;
struct str_closure * closures;
int closures_index = 0;
if((strategy_table == NULL))
strategy_table = ATtableCreate(initial_size, max_load);
closures = (struct str_closure*) malloc((sizeof(struct str_closure) * 3));
if((closures == NULL))
{
perror("malloc error for registration of dynamic strategies");
exit(1);
}
closures[closures_index].fun = &(io_wrap_1_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("io_wrap_1_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(Declare1D_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("Declare1D_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
closures[closures_index].fun = &(main_0_0);
closures[closures_index].sl = NULL;
SRTS_register_function((ATerm)ATmakeAppl0(ATmakeSymbol("main_0_0", 0, ATtrue)), &(closures[closures_index]));
closures_index++;
}
int main (int argc, char * argv [])
{
ATerm out_term;
ATermList in_term;
int i;
ATinit(argc, argv, &(out_term));
init_constructors();
in_term = ATempty;
for ( i = (argc - 1) ; (i >= 0) ; i-- )
{
in_term = ATinsert(in_term, (ATerm) ATmakeAppl0(ATmakeSymbol(argv[i], 0, ATtrue)));
}
SRTS_stratego_initialize();
memset(__tracing_table, 0, (sizeof(unsigned short) * TRACING_TABLE_SIZE));
__tracing_table_counter = 0;
register_strategies();
out_term = main_0_0(NULL, (ATerm) in_term);
if((out_term != NULL))
{
ATfprintf(stdout, "%t\n", out_term);
exit(0);
}
else
{
ATfprintf(stderr, "%s: rewriting failed, trace:\n", argv[0]);
for ( i = 0 ; (__tracing_table[i] && (i < TRACING_TABLE_SIZE)) ; i++ )
ATfprintf(stderr, "\t%s\n", __tracing_table[i]);
exit(1);
}
}
